<template>
  <div>
    <nav-header></nav-header>

    <div class="container">
      <p class="text-center">
         成功<br>
        <span>订单号:{{orderId}}</span>
        <span>订单金额:{{orderTotal}}</span>
        <router-link to="/cart">购物车列表</router-link>
        <router-link to="/">商品列表</router-link>
      </p>

    </div>
    <nav-footer></nav-footer>
  </div>
</template>

<script>
  import NavHeader from '@/components/Header'
  import NavFooter from '@/components/Footer'
  import axios from 'axios'

  export default {
    name: "orderSuccess",
    data() {
      return {
        orderId: '',
        orderTotal: 0
      }
    },
    components: {
      NavHeader,
      NavFooter,
    },
    mounted(){
      this.init()
    },
    methods: {
      init() {
        var self = this;
        var orderId = this.$route.query.orderId;
        if (!orderId) {
          return;
        }
        axios.get("/users/orderDetail", {
          params:{
            orderId: orderId
          }
        }).then(function (res) {
          var res = res.data;
          if (res.status == '0') {
            self.orderTotal = res.result.orderTotal;
            self.orderId = orderId;
            console.log("ok");
          }
        })
      }

    }
  }
</script>

<style scoped>

</style>
